#include <iostream>
#include <list>
using namespace std;

int main(){
    //定义
    list<int> L;       //空
    list<int> L1(10, 1);    //10 个 1
    list<int> L2(L1);   //复制内容
    //迭代器
    list<int>::iterator it;
    //遍历
    for(it = L1.begin();  it != L1.end(); it++){
        cout<<*it<<" ";
    }
    cout<<endl;
    //插入
    L2.push_back(9);    //尾插
    L2.push_front(8);   //头插
    it = L2.begin();
    it++;
    list<int>::iterator it2 = L2.insert(it, 100);   //返回迭代器指向插入的数据
    cout<<*it2<<endl;
    for(it = L2.begin(); it != L2.end(); it++){
        cout<<*it<<" ";
    }
    cout<<endl;

    //删除
    it = L2.begin();
    L2.erase(it);   //删除指定位置
    for(it = L2.begin(); it != L2.end(); it++){
        cout<<*it<<" ";
    }
    cout<<endl;
    // L2.erase(L2.begin(), L2.end()); //删除区间 
    //清空
    L2.clear();
    return 0;
}